package com.mall.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mall.db.domain.SearchHistory;
import com.mall.db.service.SearchHistoryService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/system/sh")
public class SearchHistoryController extends BaseController<SearchHistory>{

    @Resource(name = "searchHistoryService")
    private SearchHistoryService ss;

    @Override
    public Map<String, Object> find(SearchHistory searchHistory) {
        PageHelper.startPage(searchHistory.getPage(),searchHistory.getLimit());
        QueryWrapper qw = new QueryWrapper();
        List<SearchHistory> list = ss.list(qw);
        PageInfo<SearchHistory> page = new PageInfo<>(list,searchHistory.getLimit());
        return this.findMap(page.getList(),page.getTotal());
    }
}
